package com.kalvin.kvf.modules.xhs.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kalvin.kvf.common.utils.ShiroKit;
import com.kalvin.kvf.modules.sys.entity.User;
import org.springframework.stereotype.Service;
import com.kalvin.kvf.modules.xhs.entity.LoginUser;
import com.kalvin.kvf.modules.xhs.mapper.XhsLoginUserMapper;

import java.util.List;

/**
 * <p>
 * 服务端登录小红书账号 服务实现类
 * </p>
 * @since 2023-12-01 11:32:07
 */
@Service
public class XhsLoginUserServiceImpl extends ServiceImpl<XhsLoginUserMapper, LoginUser> implements XhsLoginUserService {

    @Override
    public Page<LoginUser> listLoginUserPage(LoginUser loginUser) {
        User user = ShiroKit.getUser();
        if(!user.getUsername().equals("admin")){
            loginUser.setPhone(user.getPhone());
        }
        Page<LoginUser> page = new Page<>(loginUser.getCurrent(), loginUser.getSize());
        List<LoginUser> loginUsers = baseMapper.selectLoginUserList(loginUser, page);
        return page.setRecords(loginUsers);
    }

}
